a=int(input("Enter the number: "))
l=[500,200,100,10,5,1]
x={}
for i in l:
x[i]=a//i
a=a%i
print(x)
Enter the number: 3475
{500: 6, 200: 2, 100: 0, 10: 7, 5: 1, 1: 0}
x=input("Enter the string: ")
a=''
b=''
for i in x:
if i.isalnum():
a=a+i
else:
b=b+a[::-1]+i
a=''
print(b+a[::-1])
Enter the string: 2233/46543/34thdb*hef56433 3322/34564/bdht43*33465feh
x=int(input("Enter the price: "))
if x>2000:
print((x/100)*20)
elif x>1500 and x<=2000:
print((x/100)*18)
elif x>1200 and x<=1500:
print((x/100)*15)
elif x>800 and x<=1200:
print((x/100)*10)
elif x>500 and x<=800:
print((x/100)*7)
elif x>300 and x<=500:
print((x/100)*5)
elif x<=300:
print(x)
Enter the price: 2500 500.0
s1={1,2,3,4}
s2={2,3,4}
s1.union(s2)
{1, 2, 3, 4}
s1 | s2
{1, 2, 3, 4}
s1 - s2
{1}
s1 & s2
{2, 3, 4}
d3={'a':[1,2],'b':[3,4]}
d4={'b':[30,40],'c':[5,6]}
d3.values()
dict_values([[1, 2], [3, 4]])
d1={'a':1,'b':2,'c':3}
d2={'b':2,'c':30,'d':4}
d={}
for k in d1.keys() & d2.keys():
d[k]=d1[k],d2[k]
print(d)
{'b': (2, 2), 'c': (3, 30)}
d1={'a':1,'b':2,'c':3}
d2={'b':2,'c':30,'d':4}
d={key:(d1[key],d2[key])for key in d1.keys() & d2.keys()}
print(d)
{'b': (2, 2), 'c': (3, 30)}
d1={'a':1,'b':2,'c':3,'d':4}
d2={'b':2,'c':30,'a':4,'e':5}
import seaborn as sns
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
cancer_df=pd.read_csv('C:\\Users\\baliy\\Downloads\\cancer.csv')
cancer_df
| mean radius | mean texture | mean perimeter | mean area | mean smoothness | mean compactness | mean concavity | mean concave points | mean symmetry | mean fractal dimension | ... | worst texture | worst perimeter | worst area | worst smoothness | worst compactness | worst concavity | worst concave points | worst symmetry | worst fractal dimension | target | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 17.99 | 10.38 | 122.80 | 1001.0 | 0.11840 | 0.27760 | 0.30010 | 0.14710 | 0.2419 | 0.07871 | ... | 17.33 | 184.60 | 2019.0 | 0.16220 | 0.66560 | 0.7119 | 0.2654 | 0.4601 | 0.11890 | 0 |
| 1 | 20.57 | 17.77 | 132.90 | 1326.0 | 0.08474 | 0.07864 | 0.08690 | 0.07017 | 0.1812 | 0.05667 | ... | 23.41 | 158.80 | 1956.0 | 0.12380 | 0.18660 | 0.2416 | 0.1860 | 0.2750 | 0.08902 | 0 |
| 2 | 19.69 | 21.25 | 130.00 | 1203.0 | 0.10960 | 0.15990 | 0.19740 | 0.12790 | 0.2069 | 0.05999 | ... | 25.53 | 152.50 | 1709.0 | 0.14440 | 0.42450 | 0.4504 | 0.2430 | 0.3613 | 0.08758 | 0 |
| 3 | 11.42 | 20.38 | 77.58 | 386.1 | 0.14250 | 0.28390 | 0.24140 | 0.10520 | 0.2597 | 0.09744 | ... | 26.50 | 98.87 | 567.7 | 0.20980 | 0.86630 | 0.6869 | 0.2575 | 0.6638 | 0.17300 | 0 |
| 4 | 20.29 | 14.34 | 135.10 | 1297.0 | 0.10030 | 0.13280 | 0.19800 | 0.10430 | 0.1809 | 0.05883 | ... | 16.67 | 152.20 | 1575.0 | 0.13740 | 0.20500 | 0.4000 | 0.1625 | 0.2364 | 0.07678 | 0 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 564 | 21.56 | 22.39 | 142.00 | 1479.0 | 0.11100 | 0.11590 | 0.24390 | 0.13890 | 0.1726 | 0.05623 | ... | 26.40 | 166.10 | 2027.0 | 0.14100 | 0.21130 | 0.4107 | 0.2216 | 0.2060 | 0.07115 | 0 |
| 565 | 20.13 | 28.25 | 131.20 | 1261.0 | 0.09780 | 0.10340 | 0.14400 | 0.09791 | 0.1752 | 0.05533 | ... | 38.25 | 155.00 | 1731.0 | 0.11660 | 0.19220 | 0.3215 | 0.1628 | 0.2572 | 0.06637 | 0 |
| 566 | 16.60 | 28.08 | 108.30 | 858.1 | 0.08455 | 0.10230 | 0.09251 | 0.05302 | 0.1590 | 0.05648 | ... | 34.12 | 126.70 | 1124.0 | 0.11390 | 0.30940 | 0.3403 | 0.1418 | 0.2218 | 0.07820 | 0 |
| 567 | 20.60 | 29.33 | 140.10 | 1265.0 | 0.11780 | 0.27700 | 0.35140 | 0.15200 | 0.2397 | 0.07016 | ... | 39.42 | 184.60 | 1821.0 | 0.16500 | 0.86810 | 0.9387 | 0.2650 | 0.4087 | 0.12400 | 0 |
| 568 | 7.76 | 24.54 | 47.92 | 181.0 | 0.05263 | 0.04362 | 0.00000 | 0.00000 | 0.1587 | 0.05884 | ... | 30.37 | 59.16 | 268.6 | 0.08996 | 0.06444 | 0.0000 | 0.0000 | 0.2871 | 0.07039 | 1 |
569 rows × 31 columns
sns.scatterplot(x='mean area',y='mean smoothness',hue='worst perimeter',data=cancer_df)
<AxesSubplot:xlabel='mean area', ylabel='mean smoothness'>
sns.countplot(cancer_df['target'])
C:\Users\baliy\anaconda3\lib\site-packages\seaborn\_decorators.py:36: FutureWarning: Pass the following variable as a keyword arg: x. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation. warnings.warn(
<AxesSubplot:xlabel='target', ylabel='count'>
sns.pairplot(cancer_df,hue="target",vars=['mean radius','mean texture','mean perimeter','mean area','mean smoothness','mean compactness','mean concavity','mean concave points','mean symmetry','mean fractal dimension','worst texture','worst perimeter','worst area','worst smoothness','worst compactness','worst concavity','worst concave points','worst symmetry','worst fractal dimension','target'])
<seaborn.axisgrid.PairGrid at 0x20083643490>
sns.pairplot(cancer_df,hue="target",vars=['mean radius','mean texture','mean perimeter','mean area'])
<seaborn.axisgrid.PairGrid at 0x1d9a1f00f10>
sns.pairplot(cancer_df,hue="target",vars=['mean radius','mean texture','mean perimeter','mean area','mean compactness'])
<seaborn.axisgrid.PairGrid at 0x1b30b9ced30>
plt.figure(figsize=(20,10))
sns.heatmap(cancer_df.corr(),annot=True)
<AxesSubplot:>
sns.distplot(cancer_df['mean radius'],bins=15,color='black')
C:\Users\baliy\anaconda3\lib\site-packages\seaborn\distributions.py:2619: FutureWarning: `distplot` is a deprecated function and will be removed in a future version. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms). warnings.warn(msg, FutureWarning)
<AxesSubplot:xlabel='mean radius', ylabel='Density'>
sns.displot(cancer_df['mean radius'],bins=15,color='black')
<seaborn.axisgrid.FacetGrid at 0x23bee96e940>
sns.distplot(cancer_df['mean radius'],bins=5,color='black')
C:\Users\baliy\anaconda3\lib\site-packages\seaborn\distributions.py:2619: FutureWarning: `distplot` is a deprecated function and will be removed in a future version. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms). warnings.warn(msg, FutureWarning)
<AxesSubplot:xlabel='mean radius', ylabel='Density'>
tips=sns.load_dataset('tips')
tips
| total_bill | tip | sex | smoker | day | time | size | |
|---|---|---|---|---|---|---|---|
| 0 | 16.99 | 1.01 | Female | No | Sun | Dinner | 2 |
| 1 | 10.34 | 1.66 | Male | No | Sun | Dinner | 3 |
| 2 | 21.01 | 3.50 | Male | No | Sun | Dinner | 3 |
| 3 | 23.68 | 3.31 | Male | No | Sun | Dinner | 2 |
| 4 | 24.59 | 3.61 | Female | No | Sun | Dinner | 4 |
| ... | ... | ... | ... | ... | ... | ... | ... |
| 239 | 29.03 | 5.92 | Male | No | Sat | Dinner | 3 |
| 240 | 27.18 | 2.00 | Female | Yes | Sat | Dinner | 2 |
| 241 | 22.67 | 2.00 | Male | Yes | Sat | Dinner | 2 |
| 242 | 17.82 | 1.75 | Male | No | Sat | Dinner | 2 |
| 243 | 18.78 | 3.00 | Female | No | Thur | Dinner | 2 |
244 rows × 7 columns
sns.relplot(x='total_bill',y='tip',data=tips)
<seaborn.axisgrid.FacetGrid at 0x206dfba0af0>
sns.relplot(x='total_bill',y='tip',data=tips,hue='time')
<seaborn.axisgrid.FacetGrid at 0x206dfd07100>
sns.relplot(x='total_bill',y='tip',data=tips,hue='smoker',style='time')
<seaborn.axisgrid.FacetGrid at 0x206dfae8c40>
sns.relplot(x='total_bill',y='tip',data=tips,size='size',sizes=(25,250))
<seaborn.axisgrid.FacetGrid at 0x206e0016ee0>
df=pd.DataFrame(dict(time=np.arange(500),value=randn(500),cumsum()))
Input In [27] df=pd.DataFrame(dict(time=np.arange(500),value=randn(500),cumsum())) ^ SyntaxError: positional argument follows keyword argument
sns.relplot(x='time',y='value',kind='line',data='df')
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Input In [28], in <cell line: 1>() ----> 1 sns.relplot(x='time',y='value',kind='line',data='df') File ~\anaconda3\lib\site-packages\seaborn\_decorators.py:46, in _deprecate_positional_args.<locals>.inner_f(*args, **kwargs) 36 warnings.warn( 37 "Pass the following variable{} as {}keyword arg{}: {}. " 38 "From version 0.12, the only valid positional argument " (...) 43 FutureWarning 44 ) 45 kwargs.update({k: arg for k, arg in zip(sig.parameters, args)}) ---> 46 return f(**kwargs) File ~\anaconda3\lib\site-packages\seaborn\relational.py:947, in relplot(x, y, hue, size, style, data, row, col, col_wrap, row_order, col_order, palette, hue_order, hue_norm, sizes, size_order, size_norm, markers, dashes, style_order, legend, kind, height, aspect, facet_kws, units, **kwargs) 944 kwargs.pop("ax") 946 # Use the full dataset to map the semantics --> 947 p = plotter( 948 data=data, 949 variables=plotter.get_semantics(locals()), 950 legend=legend, 951 ) 952 p.map_hue(palette=palette, order=hue_order, norm=hue_norm) 953 p.map_size(sizes=sizes, order=size_order, norm=size_norm) File ~\anaconda3\lib\site-packages\seaborn\relational.py:367, in _LinePlotter.__init__(self, data, variables, estimator, ci, n_boot, seed, sort, err_style, err_kws, legend) 353 def __init__( 354 self, *, 355 data=None, variables={}, (...) 361 # the kind of plot to draw, but for the time being we need to set 362 # this information so the SizeMapping can use it 363 self._default_size_range = ( 364 np.r_[.5, 2] * mpl.rcParams["lines.linewidth"] 365 ) --> 367 super().__init__(data=data, variables=variables) 369 self.estimator = estimator 370 self.ci = ci File ~\anaconda3\lib\site-packages\seaborn\_core.py:605, in VectorPlotter.__init__(self, data, variables) 603 def __init__(self, data=None, variables={}): --> 605 self.assign_variables(data, variables) 607 for var, cls in self._semantic_mappings.items(): 608 609 # Create the mapping function 610 map_func = partial(cls.map, plotter=self) File ~\anaconda3\lib\site-packages\seaborn\_core.py:668, in VectorPlotter.assign_variables(self, data, variables) 666 else: 667 self.input_format = "long" --> 668 plot_data, variables = self._assign_variables_longform( 669 data, **variables, 670 ) 672 self.plot_data = plot_data 673 self.variables = variables File ~\anaconda3\lib\site-packages\seaborn\_core.py:903, in VectorPlotter._assign_variables_longform(self, data, **kwargs) 898 elif isinstance(val, (str, bytes)): 899 900 # This looks like a column name but we don't know what it means! 902 err = f"Could not interpret value `{val}` for parameter `{key}`" --> 903 raise ValueError(err) 905 else: 906 907 # Otherwise, assume the value is itself data 908 909 # Raise when data object is present and a vector can't matched 910 if isinstance(data, pd.DataFrame) and not isinstance(val, pd.Series): ValueError: Could not interpret value `time` for parameter `x`